home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / mallcrawl.swf / scripts / __Packages / mx / core / UIObject.as < prev    next >
Encoding:
Text File  |  2007-09-28  |  15.6 KB  |  631 lines

  1. class mx.core.UIObject extends MovieClip
  2. {
  3.    var _minHeight;
  4.    var _minWidth;
  5.    var dispatchEvent;
  6.    var methodTable;
  7.    var onEnterFrame;
  8.    var tfList;
  9.    var __width;
  10.    var __height;
  11.    var buildDepthTable;
  12.    var findNextAvailableDepth;
  13.    var idNames;
  14.    var childrenCreated;
  15.    var createAccessibilityImplementation;
  16.    var _endInit;
  17.    var validateNow;
  18.    var initProperties;
  19.    var stylecache;
  20.    var className;
  21.    var ignoreClassStyleDeclaration;
  22.    var _tf;
  23.    var fontFamily;
  24.    var fontSize;
  25.    var color;
  26.    var marginLeft;
  27.    var marginRight;
  28.    var fontStyle;
  29.    var fontWeight;
  30.    var textAlign;
  31.    var textIndent;
  32.    var textDecoration;
  33.    var embedFonts;
  34.    var styleName;
  35.    static var symbolName = "UIObject";
  36.    static var symbolOwner = mx.core.UIObject;
  37.    static var version = "2.0.2.126";
  38.    static var textColorList = {color:1,disabledColor:1};
  39.    var invalidateFlag = false;
  40.    var lineWidth = 1;
  41.    var lineColor = 0;
  42.    var tabEnabled = false;
  43.    var clipParameters = {visible:1,minHeight:1,minWidth:1,maxHeight:1,maxWidth:1,preferredHeight:1,preferredWidth:1};
  44.    function UIObject()
  45.    {
  46.       super();
  47.       this.constructObject();
  48.    }
  49.    function get width()
  50.    {
  51.       return this._width;
  52.    }
  53.    function get height()
  54.    {
  55.       return this._height;
  56.    }
  57.    function get left()
  58.    {
  59.       return this._x;
  60.    }
  61.    function get x()
  62.    {
  63.       return this._x;
  64.    }
  65.    function get top()
  66.    {
  67.       return this._y;
  68.    }
  69.    function get y()
  70.    {
  71.       return this._y;
  72.    }
  73.    function get right()
  74.    {
  75.       return this._parent.width - (this._x + this.width);
  76.    }
  77.    function get bottom()
  78.    {
  79.       return this._parent.height - (this._y + this.height);
  80.    }
  81.    function getMinHeight(Void)
  82.    {
  83.       return this._minHeight;
  84.    }
  85.    function setMinHeight(h)
  86.    {
  87.       this._minHeight = h;
  88.    }
  89.    function get minHeight()
  90.    {
  91.       return this.getMinHeight();
  92.    }
  93.    function set minHeight(h)
  94.    {
  95.       this.setMinHeight(h);
  96.    }
  97.    function getMinWidth(Void)
  98.    {
  99.       return this._minWidth;
  100.    }
  101.    function setMinWidth(w)
  102.    {
  103.       this._minWidth = w;
  104.    }
  105.    function get minWidth()
  106.    {
  107.       return this.getMinWidth();
  108.    }
  109.    function set minWidth(w)
  110.    {
  111.       this.setMinWidth(w);
  112.    }
  113.    function setVisible(x, noEvent)
  114.    {
  115.       if(x != this._visible)
  116.       {
  117.          this._visible = x;
  118.          if(noEvent != true)
  119.          {
  120.             this.dispatchEvent({type:(!x ? "hide" : "reveal")});
  121.          }
  122.       }
  123.    }
  124.    function get visible()
  125.    {
  126.       return this._visible;
  127.    }
  128.    function set visible(x)
  129.    {
  130.       this.setVisible(x,false);
  131.    }
  132.    function get scaleX()
  133.    {
  134.       return this._xscale;
  135.    }
  136.    function set scaleX(x)
  137.    {
  138.       this._xscale = x;
  139.    }
  140.    function get scaleY()
  141.    {
  142.       return this._yscale;
  143.    }
  144.    function set scaleY(y)
  145.    {
  146.       this._yscale = y;
  147.    }
  148.    function doLater(obj, fn)
  149.    {
  150.       if(this.methodTable == undefined)
  151.       {
  152.          this.methodTable = new Array();
  153.       }
  154.       this.methodTable.push({obj:obj,fn:fn});
  155.       this.onEnterFrame = this.doLaterDispatcher;
  156.    }
  157.    function doLaterDispatcher(Void)
  158.    {
  159.       delete this.onEnterFrame;
  160.       if(this.invalidateFlag)
  161.       {
  162.          this.redraw();
  163.       }
  164.       var _loc3_ = this.methodTable;
  165.       this.methodTable = new Array();
  166.       if(_loc3_.length > 0)
  167.       {
  168.          var _loc2_ = undefined;
  169.          while((_loc2_ = _loc3_.shift()) != undefined)
  170.          {
  171.             _loc2_.obj[_loc2_.fn]();
  172.          }
  173.       }
  174.    }
  175.    function cancelAllDoLaters(Void)
  176.    {
  177.       delete this.onEnterFrame;
  178.       this.methodTable = new Array();
  179.    }
  180.    function invalidate(Void)
  181.    {
  182.       this.invalidateFlag = true;
  183.       this.onEnterFrame = this.doLaterDispatcher;
  184.    }
  185.    function invalidateStyle(Void)
  186.    {
  187.       this.invalidate();
  188.    }
  189.    function redraw(bAlways)
  190.    {
  191.       if(this.invalidateFlag || bAlways)
  192.       {
  193.          this.invalidateFlag = false;
  194.          var _loc2_ = undefined;
  195.          for(_loc2_ in this.tfList)
  196.          {
  197.             this.tfList[_loc2_].draw();
  198.          }
  199.          this.draw();
  200.          this.dispatchEvent({type:"draw"});
  201.       }
  202.    }
  203.    function draw(Void)
  204.    {
  205.    }
  206.    function move(x, y, noEvent)
  207.    {
  208.       var _loc3_ = this._x;
  209.       var _loc2_ = this._y;
  210.       this._x = x;
  211.       this._y = y;
  212.       if(noEvent != true)
  213.       {
  214.          this.dispatchEvent({type:"move",oldX:_loc3_,oldY:_loc2_});
  215.       }
  216.    }
  217.    function setSize(w, h, noEvent)
  218.    {
  219.       var _loc2_ = this.__width;
  220.       var _loc3_ = this.__height;
  221.       this.__width = w;
  222.       this.__height = h;
  223.       this.size();
  224.       if(noEvent != true)
  225.       {
  226.          this.dispatchEvent({type:"resize",oldWidth:_loc2_,oldHeight:_loc3_});
  227.       }
  228.    }
  229.    function size(Void)
  230.    {
  231.       this._width = this.__width;
  232.       this._height = this.__height;
  233.    }
  234.    function drawRect(x1, y1, x2, y2)
  235.    {
  236.       this.moveTo(x1,y1);
  237.       this.lineTo(x2,y1);
  238.       this.lineTo(x2,y2);
  239.       this.lineTo(x1,y2);
  240.       this.lineTo(x1,y1);
  241.    }
  242.    function createLabel(name, depth, text)
  243.    {
  244.       this.createTextField(name,depth,0,0,0,0);
  245.       var _loc2_ = this[name];
  246.       _loc2_._color = mx.core.UIObject.textColorList;
  247.       _loc2_._visible = false;
  248.       _loc2_.__text = text;
  249.       if(this.tfList == undefined)
  250.       {
  251.          this.tfList = new Object();
  252.       }
  253.       this.tfList[name] = _loc2_;
  254.       _loc2_.invalidateStyle();
  255.       this.invalidate();
  256.       _loc2_.styleName = this;
  257.       return _loc2_;
  258.    }
  259.    function createObject(linkageName, id, depth, initobj)
  260.    {
  261.       return this.attachMovie(linkageName,id,depth,initobj);
  262.    }
  263.    function createClassObject(className, id, depth, initobj)
  264.    {
  265.       var _loc3_ = className.symbolName == undefined;
  266.       if(_loc3_)
  267.       {
  268.          Object.registerClass(className.symbolOwner.symbolName,className);
  269.       }
  270.       var _loc4_ = this.createObject(className.symbolOwner.symbolName,id,depth,initobj);
  271.       if(_loc3_)
  272.       {
  273.          Object.registerClass(className.symbolOwner.symbolName,className.symbolOwner);
  274.       }
  275.       return _loc4_;
  276.    }
  277.    function createEmptyObject(id, depth)
  278.    {
  279.       return this.createClassObject(mx.core.UIObject,id,depth);
  280.    }
  281.    function destroyObject(id)
  282.    {
  283.       var _loc2_ = this[id];
  284.       if(_loc2_.getDepth() < 0)
  285.       {
  286.          var _loc4_ = this.buildDepthTable();
  287.          var _loc5_ = this.findNextAvailableDepth(0,_loc4_,"up");
  288.          var _loc3_ = _loc5_;
  289.          _loc2_.swapDepths(_loc3_);
  290.       }
  291.       _loc2_.removeMovieClip();
  292.       delete this[id];
  293.    }
  294.    function getSkinIDName(tag)
  295.    {
  296.       return this.idNames[tag];
  297.    }
  298.    function setSkin(tag, linkageName, initObj)
  299.    {
  300.       if(_global.skinRegistry[linkageName] == undefined)
  301.       {
  302.          mx.skins.SkinElement.registerElement(linkageName,mx.skins.SkinElement);
  303.       }
  304.       return this.createObject(linkageName,this.getSkinIDName(tag),tag,initObj);
  305.    }
  306.    function createSkin(tag)
  307.    {
  308.       var _loc2_ = this.getSkinIDName(tag);
  309.       this.createEmptyObject(_loc2_,tag);
  310.       return this[_loc2_];
  311.    }
  312.    function createChildren(Void)
  313.    {
  314.    }
  315.    function _createChildren(Void)
  316.    {
  317.       this.createChildren();
  318.       this.childrenCreated = true;
  319.    }
  320.    function constructObject(Void)
  321.    {
  322.       if(this._name == undefined)
  323.       {
  324.          return undefined;
  325.       }
  326.       this.init();
  327.       this._createChildren();
  328.       this.createAccessibilityImplementation();
  329.       this._endInit();
  330.       if(this.validateNow)
  331.       {
  332.          this.redraw(true);
  333.       }
  334.       else
  335.       {
  336.          this.invalidate();
  337.       }
  338.    }
  339.    function initFromClipParameters(Void)
  340.    {
  341.       var _loc4_ = false;
  342.       var _loc2_ = undefined;
  343.       for(_loc2_ in this.clipParameters)
  344.       {
  345.          if(this.hasOwnProperty(_loc2_))
  346.          {
  347.             _loc4_ = true;
  348.             this["def_" + _loc2_] = this[_loc2_];
  349.             delete this[_loc2_];
  350.          }
  351.       }
  352.       if(_loc4_)
  353.       {
  354.          for(_loc2_ in this.clipParameters)
  355.          {
  356.             var _loc3_ = this["def_" + _loc2_];
  357.             if(_loc3_ != undefined)
  358.             {
  359.                this[_loc2_] = _loc3_;
  360.             }
  361.          }
  362.       }
  363.    }
  364.    function init(Void)
  365.    {
  366.       this.__width = this._width;
  367.       this.__height = this._height;
  368.       if(this.initProperties == undefined)
  369.       {
  370.          this.initFromClipParameters();
  371.       }
  372.       else
  373.       {
  374.          this.initProperties();
  375.       }
  376.       if(_global.cascadingStyles == true)
  377.       {
  378.          this.stylecache = new Object();
  379.       }
  380.    }
  381.    function getClassStyleDeclaration(Void)
  382.    {
  383.       var _loc4_ = this;
  384.       var _loc3_ = this.className;
  385.       while(_loc3_ != undefined)
  386.       {
  387.          if(this.ignoreClassStyleDeclaration[_loc3_] == undefined)
  388.          {
  389.             if(_global.styles[_loc3_] != undefined)
  390.             {
  391.                return _global.styles[_loc3_];
  392.             }
  393.          }
  394.          _loc4_ = _loc4_.__proto__;
  395.          _loc3_ = _loc4_.className;
  396.       }
  397.    }
  398.    function setColor(color)
  399.    {
  400.    }
  401.    function __getTextFormat(tf, bAll)
  402.    {
  403.       var _loc8_ = this.stylecache.tf;
  404.       if(_loc8_ != undefined)
  405.       {
  406.          var _loc3_ = undefined;
  407.          for(_loc3_ in mx.styles.StyleManager.TextFormatStyleProps)
  408.          {
  409.             if(bAll || mx.styles.StyleManager.TextFormatStyleProps[_loc3_])
  410.             {
  411.                if(tf[_loc3_] == undefined)
  412.                {
  413.                   tf[_loc3_] = _loc8_[_loc3_];
  414.                }
  415.             }
  416.          }
  417.          return false;
  418.       }
  419.       var _loc6_ = false;
  420.       for(_loc3_ in mx.styles.StyleManager.TextFormatStyleProps)
  421.       {
  422.          if(bAll || mx.styles.StyleManager.TextFormatStyleProps[_loc3_])
  423.          {
  424.             if(tf[_loc3_] == undefined)
  425.             {
  426.                var _loc5_ = this._tf[_loc3_];
  427.                if(_loc5_ != undefined)
  428.                {
  429.                   tf[_loc3_] = _loc5_;
  430.                }
  431.                else if(_loc3_ == "font" && this.fontFamily != undefined)
  432.                {
  433.                   tf[_loc3_] = this.fontFamily;
  434.                }
  435.                else if(_loc3_ == "size" && this.fontSize != undefined)
  436.                {
  437.                   tf[_loc3_] = this.fontSize;
  438.                }
  439.                else if(_loc3_ == "color" && this.color != undefined)
  440.                {
  441.                   tf[_loc3_] = this.color;
  442.                }
  443.                else if(_loc3_ == "leftMargin" && this.marginLeft != undefined)
  444.                {
  445.                   tf[_loc3_] = this.marginLeft;
  446.                }
  447.                else if(_loc3_ == "rightMargin" && this.marginRight != undefined)
  448.                {
  449.                   tf[_loc3_] = this.marginRight;
  450.                }
  451.                else if(_loc3_ == "italic" && this.fontStyle != undefined)
  452.                {
  453.                   tf[_loc3_] = this.fontStyle == _loc3_;
  454.                }
  455.                else if(_loc3_ == "bold" && this.fontWeight != undefined)
  456.                {
  457.                   tf[_loc3_] = this.fontWeight == _loc3_;
  458.                }
  459.                else if(_loc3_ == "align" && this.textAlign != undefined)
  460.                {
  461.                   tf[_loc3_] = this.textAlign;
  462.                }
  463.                else if(_loc3_ == "indent" && this.textIndent != undefined)
  464.                {
  465.                   tf[_loc3_] = this.textIndent;
  466.                }
  467.                else if(_loc3_ == "underline" && this.textDecoration != undefined)
  468.                {
  469.                   tf[_loc3_] = this.textDecoration == _loc3_;
  470.                }
  471.                else if(_loc3_ == "embedFonts" && this.embedFonts != undefined)
  472.                {
  473.                   tf[_loc3_] = this.embedFonts;
  474.                }
  475.                else
  476.                {
  477.                   _loc6_ = true;
  478.                }
  479.             }
  480.          }
  481.       }
  482.       if(_loc6_)
  483.       {
  484.          var _loc9_ = this.styleName;
  485.          if(_loc9_ != undefined)
  486.          {
  487.             if(typeof _loc9_ != "string")
  488.             {
  489.                _loc6_ = _loc9_.__getTextFormat(tf,true,this);
  490.             }
  491.             else if(_global.styles[_loc9_] != undefined)
  492.             {
  493.                _loc6_ = _global.styles[_loc9_].__getTextFormat(tf,true,this);
  494.             }
  495.          }
  496.       }
  497.       if(_loc6_)
  498.       {
  499.          var _loc10_ = this.getClassStyleDeclaration();
  500.          if(_loc10_ != undefined)
  501.          {
  502.             _loc6_ = _loc10_.__getTextFormat(tf,true,this);
  503.          }
  504.       }
  505.       if(_loc6_)
  506.       {
  507.          if(_global.cascadingStyles)
  508.          {
  509.             if(this._parent != undefined)
  510.             {
  511.                _loc6_ = this._parent.__getTextFormat(tf,false);
  512.             }
  513.          }
  514.       }
  515.       if(_loc6_)
  516.       {
  517.          _loc6_ = _global.style.__getTextFormat(tf,true,this);
  518.       }
  519.       return _loc6_;
  520.    }
  521.    function _getTextFormat(Void)
  522.    {
  523.       var _loc2_ = this.stylecache.tf;
  524.       if(_loc2_ != undefined)
  525.       {
  526.          return _loc2_;
  527.       }
  528.       _loc2_ = new TextFormat();
  529.       this.__getTextFormat(_loc2_,true);
  530.       this.stylecache.tf = _loc2_;
  531.       if(this.enabled == false)
  532.       {
  533.          var _loc3_ = this.getStyle("disabledColor");
  534.          _loc2_.color = _loc3_;
  535.       }
  536.       return _loc2_;
  537.    }
  538.    function getStyleName(Void)
  539.    {
  540.       var _loc2_ = this.styleName;
  541.       if(_loc2_ != undefined)
  542.       {
  543.          if(typeof _loc2_ != "string")
  544.          {
  545.             return _loc2_.getStyleName();
  546.          }
  547.          return _loc2_;
  548.       }
  549.       if(this._parent != undefined)
  550.       {
  551.          return this._parent.getStyleName();
  552.       }
  553.       return undefined;
  554.    }
  555.    function getStyle(styleProp)
  556.    {
  557.       var _loc3_ = undefined;
  558.       _global.getStyleCounter = _global.getStyleCounter + 1;
  559.       if(this[styleProp] != undefined)
  560.       {
  561.          return this[styleProp];
  562.       }
  563.       var _loc6_ = this.styleName;
  564.       if(_loc6_ != undefined)
  565.       {
  566.          if(typeof _loc6_ != "string")
  567.          {
  568.             _loc3_ = _loc6_.getStyle(styleProp);
  569.          }
  570.          else
  571.          {
  572.             var _loc7_ = _global.styles[_loc6_];
  573.             _loc3_ = _loc7_.getStyle(styleProp);
  574.          }
  575.       }
  576.       if(_loc3_ != undefined)
  577.       {
  578.          return _loc3_;
  579.       }
  580.       _loc7_ = this.getClassStyleDeclaration();
  581.       if(_loc7_ != undefined)
  582.       {
  583.          _loc3_ = _loc7_[styleProp];
  584.       }
  585.       if(_loc3_ != undefined)
  586.       {
  587.          return _loc3_;
  588.       }
  589.       if(_global.cascadingStyles)
  590.       {
  591.          if(mx.styles.StyleManager.isInheritingStyle(styleProp) || mx.styles.StyleManager.isColorStyle(styleProp))
  592.          {
  593.             var _loc5_ = this.stylecache;
  594.             if(_loc5_ != undefined)
  595.             {
  596.                if(_loc5_[styleProp] != undefined)
  597.                {
  598.                   return _loc5_[styleProp];
  599.                }
  600.             }
  601.             if(this._parent != undefined)
  602.             {
  603.                _loc3_ = this._parent.getStyle(styleProp);
  604.             }
  605.             else
  606.             {
  607.                _loc3_ = _global.style[styleProp];
  608.             }
  609.             if(_loc5_ != undefined)
  610.             {
  611.                _loc5_[styleProp] = _loc3_;
  612.             }
  613.             return _loc3_;
  614.          }
  615.       }
  616.       if(_loc3_ == undefined)
  617.       {
  618.          _loc3_ = _global.style[styleProp];
  619.       }
  620.       return _loc3_;
  621.    }
  622.    static function mergeClipParameters(o, p)
  623.    {
  624.       for(var _loc3_ in p)
  625.       {
  626.          o[_loc3_] = p[_loc3_];
  627.       }
  628.       return true;
  629.    }
  630. }
  631.